
$(document).ready(function(){
	WantAllInfo();
	GoToPay();
});
//请求所有订单信息
var WantAllInfo = function(){
	var orderid = $("div.rentrepay_hidden_orderid").text();
	//模拟数据
//	var orderid = "d93e67a8611d4660871bc5a978223bf3";
	$.ajax({	
		dataType : "json",
		type : "post",
		url : basePath+"/line/lineorderinfo",
		data : {
			orderid:orderid
		},
		
		contentType : "application/x-www-form-urlencoded;charset=utf-8",
		success : function(data) {
			var num = "订单号：" + data.data.num;
			var imgurl = data.data.imgurl;
			var title = data.data.title;
			var start = data.data.begindate +  "(" + data.data.beginday + ")" + "出发";
			var end = data.data.enddate + "(" + data.data.endday + ")" + "返回";
			var city = data.data.city;
			var tranum = "出游人数：" + data.data.adult + "成人，" + data.data.child + "儿童"; 
			var name = data.data.name;
			var phone = data.data.phone;
			var email = data.data.email;
			var message = data.data.message;
			var price = data.data.price;
			var state = data.data.state;
			//设置title
			$(document).attr("title","订单详情_"+title);//修改title值  
			
			$("div.rentrepay_sign_order_down").text(num);
			$("img.rentrepay_info_pic_posi").attr("src",imgurl);
			$("div.linerepay_info_detail_title").text(title);
			$("div.linerepay_info_detail_time_right_one").text(start);
			$("div.linerepay_info_detail_timeother").text(end);
			$("div.linerepay_info_detail_city_one:eq(1)").text(city);
			$("div.linerepay_info_detail_num_detail").text(tranum);
			$("div.rentrepay_contacts_two_item_detail:eq(0)").text(name);
			$("div.rentrepay_contacts_two_item_detail:eq(1)").text(phone);
			if(email == null || email == ""){
				$("div.rentrepay_contacts_two_item_detail:eq(2)").text("邮箱未提供");
			}else{
				$("div.rentrepay_contacts_two_item_detail:eq(2)").text(email);
			}
			
			$("div.linerepay_info_detail_mes").text(message);
			$("div#orderallprice").text(price);
			
			var p = "";
			for(var i = 0;i<data.data.orderdetail.length;i++){
				p = p +   "<div class=\"rentrepay_info_price_detail_item\">\n"+
								"<div class=\"rentrepay_info_price_detail_item_one\">"+data.data.orderdetail[i].name+"</div>\n"+
								"<div class=\"rentrepay_info_price_detail_item_two\"></div>\n"+
								"<div class=\"rentrepay_info_price_detail_item_three\">\n"+
									"<div class=\"rentrepay_info_price_detail_item_three_sign\"></div>\n"+
									"<div class=\"rentrepay_info_price_detail_item_three_price\">"+data.data.orderdetail[i].price+"</div>\n"+
								"</div>\n"+
							"</div>"
			};
			$("div.rentrepay_info_price_detail").html(p);
			
			var a = "";
			var k = "";
			var an = 1;
			var kn = 1;
			for(var i = 0;i<data.data.travellers.length;i++){
				if(data.data.travellers[i].type === "成人"){
					var tp = (data.data.travellers[i].phone === undefined?"未提供":data.data.travellers[i].phone);
					a = a + "<div class=\"linerepay_traveller_detail_adult_item\">\n"+
							"<div class=\"linerepay_traveller_detail_adult_one\">\n"+
								"<div class=\"linerepay_traveller_detail_adult_one_up\">第"+an+"位</div>\n"+
								"<div class=\"linerepay_traveller_detail_adult_one_down\">成人</div>\n"+
							"</div>\n"+
							"<div class=\"linerepay_traveller_detail_adult_two\">\n"+
								"<div class=\"linerepay_traveller_detail_adult_two_item\">\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_name\">姓名：</div>\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_detal\">"+data.data.travellers[i].name+"</div>\n"+
								"</div>\n"+
								"<div class=\"linerepay_traveller_detail_adult_two_item\">\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_name\">身份证号：</div>\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_detal\">"+data.data.travellers[i].num+"</div>\n"+
								"</div>\n"+
								"<div class=\"linerepay_traveller_detail_adult_two_item\">\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_name\">手机号：</div>\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_detal\">"+tp+"</div>\n"+
								"</div>"+
							"</div>\n"+
							"</div>";
					an += 1;
				}else{
					k = k + "<div class=\"linerepay_traveller_detail_kids_item\">\n"+
							"<div class=\"linerepay_traveller_detail_adult_one\">\n"+
								"<div class=\"linerepay_traveller_detail_adult_one_up\">第"+ kn +"位</div>\n"+
								"<div class=\"linerepay_traveller_detail_adult_one_down\">儿童</div>\n"+
							"</div>\n"+
							"<div class=\"linerepay_traveller_detail_adult_two\">\n"+
								"<div class=\"linerepay_traveller_detail_adult_two_item\">\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_name\">姓名：</div>\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_detal\">"+data.data.travellers[i].name+"</div>\n"+
								"</div>\n"+
								"<div class=\"linerepay_traveller_detail_adult_two_item\">\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_name\">身份证号：</div>\n"+
									"<div class=\"linerepay_traveller_detail_adult_two_item_detal\">"+data.data.travellers[i].num+"</div>\n"+
								"</div>\n"+
							"</div>\n"+
						"</div>"
					kn += 1;		
				};
				$("div.linerepay_traveller_detail_adult").html(a);
				$("div.linerepay_traveller_detail_kids").html(k);
				
			};
			
			if(state == "2"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单预定成功");
			};
			if(state == "3"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单预定成功");
			};
			if(state == "4"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单出行中");
			};
			if(state == "5"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单已完成");
			};
			if(state == "6"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单确认完成");
			};
			if(state == "7"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单申请退款中");
			};
			if(state == "8"){
				$("input.rentrepay_sign_nav_b").fadeOut();
				$("div.rentrepay_sign_order_up").addClass("rentrepay_sign_order_upover");
				$("div.rentrepay_sign_order_up").text("订单退款成功");
			};
		},
		error : function() {
			console.log("访问失败");
		},
		complete : function() {
			layer.close(LoadingIcon);
		},
	});
}
//点击立即支付跳转订单支付页面
var GoToPay = function(){
	$("input.rentrepay_sign_nav_b").click(function(){
		var orderid = $("div.rentrepay_hidden_orderid").text();
		url = basePath + "/linepay?lineorderid="+orderid;
		window.open(url);
//		window.location.href = (url);
	});
}